Returns a Date value for a specified year, month, or day.
指定された年、月、日に該当する、日付 データを返します。
DateSerial (year, month, day)
DateSerial (year, month, day)
Date
日付
Year: Integer expression that indicates a year. All values between 0 and 99 are interpreted as the years 1900-1999. For years that fall outside this range, you must enter all four digits.
Year: 年を指定する整数表式。0 から 99 の数値は、1900 から 1999 の該当年として解釈されますが、その他の数値は 4 桁すべてを指定する必要があります。
Month: Integer expression that indicates the month of the specified year. The accepted range is from 1-12.
Month: 月を指定する整数表式。1 から 12 の数値を指定できます。
Day: Integer expression that indicates the day of the specified month. The accepted range is from 1-31. No error is returned when you enter a non-existing day for a month shorter than 31 days.
日: 指定された月の日を示す整数式。許容範囲は 1 ~ 31 です。31 日より小さい存在しない日付を入力しても、エラーは返されません。
The DateSerial function returns the number of days between December 30,1899 and the given date. You can use this function to calculate the difference between two dates.
DateSerial 関数 は、1899 年 12 月 30 日からの経過日数を返します。この関数で得られる数値は、2 つの日付間の日数計算などに利用できます。
The DateSerial function returns the data type Variant with VarType 7 (Date). Internally, this value is stored as a Double value, so that when the given date is 1.1.1900, the returned value is 2. Negative values correspond to dates before December 30, 1899 (not inclusive).
DateSerial 関数 の返す値は、バリアント型の VarType 7 (Date) です。この値は内部的には倍精度値として格納され、たとえば1900/1/1という日付を指定すると、2 という値が返されます。また、基準日となる 1899 年 12 月 30 日以前の日付 (範囲外の日付) は、負の値として処理されます。
If a date is defined that lies outside of the accepted range, Office Basic returns an error message.
処理範囲外の日付を指定すると、Office Basic からはエラーメッセージが返されます。
Whereas you define the DateValue function as a string that contains the date, the DateSerial function evaluates each of the parameters (year, month, day) as separate numeric expressions.
DateValue 関数 では日付を 1 つの文字列として指定するのに対して、DateSerial 関数 の場合は各パラメータ (年、月、日) を、それぞれ個別に評価します。
Sub ExampleDateSerial
Sub ExampleDateSerial
Dim lDate as Long
Dim lDate as Long
Dim sDate as String
Dim sDate as String
lDate = DateSerial(1964, 4, 9)
lDate = DateSerial(1964, 4, 9)
sDate = DateSerial(1964, 4, 9)
sDate = DateSerial(1964, 4, 9)
msgbox lDate REM returns 23476
msgbox lDate REM 戻り値は 23476
msgbox sDate REM returns 04/09/1964
msgbox sDate REM は 04/09/1964 を返します
end sub
end sub